package com.huffman.smart_picture.domain.vo.pircture;

import cn.hutool.json.JSONUtil;
import com.huffman.smart_picture.domain.entity.Picture;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * @author DengLin
 * @title 管理员审核图片信息vo
 * @date 2025/4/11
 */
@Data
public class PictureViewVo {
    /**
     * id
     */
    private Long id;

    /**
     * 图片 url
     */
    private String url;

    /**
     * 图片名称
     */
    private String picName;

    /**
     * 简介
     */
    private String introduction;

    /**
     * 分类
     */
    private String category;

    /**
     * 标签
     */
    private List<String> tags;

    /**
     * 图片体积
     */
    private Long picSize;

    /**
     * 图片宽度
     */
    private Integer picWidth;

    /**
     * 图片高度
     */
    private Integer picHeight;

    /**
     * 图片宽高比例
     */
    private Double picScale;

    /**
     * 图片格式
     */
    private String picFormat;

    /**
     * 创建用户 id
     */
    private Long userId;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 审核状态：0-待审核; 1-通过; 2-拒绝
     */
    private Integer reviewStatus;

    /**
     * 审核信息
     */
    private String reviewMessage;

    /**
     * 审核人 ID
     */
    private Long reviewerId;

    /**
     * 审核时间
     */
    private Date reviewTime;

    /**
     * 缩略图 url
     */
    private String thumbnailUrl;

    public static PictureViewVo convert(Picture picture) {
        PictureViewVo pictureViewVo = new PictureViewVo();
        pictureViewVo.setId(picture.getId());
        pictureViewVo.setUrl(picture.getUrl());
        pictureViewVo.setPicName(picture.getPicName());
        pictureViewVo.setIntroduction(picture.getIntroduction());
        pictureViewVo.setCategory(picture.getCategory());
        pictureViewVo.setTags(JSONUtil.toList(picture.getTags(), String.class));
        pictureViewVo.setPicSize(picture.getPicSize());
        pictureViewVo.setPicWidth(picture.getPicWidth());
        pictureViewVo.setPicHeight(picture.getPicHeight());
        pictureViewVo.setPicScale(picture.getPicScale());
        pictureViewVo.setPicFormat(picture.getPicFormat());
        pictureViewVo.setUserId(picture.getUserId());
        pictureViewVo.setCreateTime(picture.getCreateTime());
        pictureViewVo.setUpdateTime(picture.getUpdateTime());
        pictureViewVo.setReviewStatus(picture.getReviewStatus());
        pictureViewVo.setReviewMessage(picture.getReviewMessage());
        pictureViewVo.setReviewerId(picture.getReviewerId());
        pictureViewVo.setReviewTime(picture.getReviewTime());
        pictureViewVo.setThumbnailUrl(picture.getThumbnailUrl());
        return pictureViewVo;
    }

}
